<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<script type="text/javascript" src="js/jquery-1.11.3.min.js"></script>
<style type="text/css">
	div{
		width: 200px;
		height: 200px;
		border: 1px solid red;
	}
</style>
<body>
	<div id="aa">我是search传参?yzm,变红</div>
	<div id="bb">我是hash传参#yzm,变绿</div>
	<div id="cc">我是cookie传参,变黄</div>
</body>
<script type="text/javascript">
	// var search=location.search.substring(1).charAt(0); 取?一位数没有?
	var search=location.search.substring(1);  //取所有没有?
	var hash=location.hash;  //取所有包括#
	var aa=document.getElementById("aa");
	var bb=document.getElementById("bb");
	var cc=document.getElementById("cc");
	if(search == "[1,2,3]"){
		aa.style.background="red";
	} 
	if(hash == "#yzm"){
		bb.style.background="green";
	}
	// cookie取值
	function getCookie(cookieName) {
	    var strCookie = document.cookie;
	    var arrCookie = strCookie.split("; ");
	    for(var i = 0; i < arrCookie.length; i++){
	        var arr = arrCookie[i].split("=");
	        if(cookieName == arr[0]){ //在cookie里找出name为name的值,arr[0]是name值,arr[1]是key值
	            alert(arr[0]+'----'+arr[1]);//name和key
	        }
	    }
	}
	getCookie('name');//name值
</script>
</html>